package com.system.result;

public class Result<T> {
	
	private String result;
	private String msg;
	private T pd;
	
	/**
	 *  成功时候的调用
	 * */
	public static  <T> Result<T> success(T data){
		return new Result<T>(data);
	}
	
	/**
	 *  失败时候的调用(带数据)
	 * */
	public static  <T> Result<T> error_data(CodeMsg codeMsg,T data){
		return new Result<T>(codeMsg,data);
	}
	
	/**
	 *  失败时候的调用
	 * */
	public static  <T> Result<T> error(CodeMsg codeMsg){
		return new Result<T>(codeMsg);
	}
	
	private Result(T pd) {
		this.result = "01";
		this.msg = "请求成功";
		this.pd = pd;
	}
	
	private Result(CodeMsg codeMsg) {
		if(codeMsg != null) {
			this.result = codeMsg.getCode();
			this.msg = codeMsg.getMsg();
		}
	}
	
	
	public Result(CodeMsg codeMsg, T data) {
		this.result = codeMsg.getCode();
		this.msg = codeMsg.getMsg();
		this.pd = data;
	}

	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public T getPd() {
		return pd;
	}

	public void setPd(T pd) {
		this.pd = pd;
	}
}
